import Vue from 'vue'
import App from './App.vue'
//1 下载vue-router模块
// 2 把main.js引入到模块
import VueRouter from "vue-router"
// 3把它注册到vue原型上
Vue.use(VueRouter)
Vue.config.productionTip = false

//4  定义规则
import Home from "./views/Home.vue"
import Movie from "./views/Movie.vue"
import About from "./views/About.vue"
import MyGoods from "./views/MyGoods.vue"
import NotFound from "./components/NotFound.vue"
// 规则对象
const routes = [{
    path: "/",
    // 重定向
    redirect: "/home"
  }, {
    path: "/home",
    component: Home
  }, {
    path: "/movie",
    component: Movie
  }, {
    path: "/about",
    component: About
  }, {
    path: '/goods',
    name: "theGoods",
    component: MyGoods
  },
  {
    // 动态路由:路径上加了冒号 :变量名
    //以后对应路径要接收的值
    //使用:要一个个路径对应上
    path: '/goods/:gname',
    component: MyGoods
  }, {
    path: '*',
    component: NotFound
  }
]
// 5用规则生成路由对象
const router = new VueRouter({
  routes,
  // 设置路由模式
  mode: "history"
})
new Vue({
  render: h => h(App),
  router
}).$mount('#app')